//
//  TypeBtn.m
//  代理端
//
//  Created by mac on 16/3/2.
//  Copyright © 2016年 sliver. All rights reserved.
//

#import "TypeBtn.h"
@interface TypeBtn()


@end
@implementation TypeBtn

- (instancetype)init
{
    self = [super init];
    if (self) {
        UIImageView *imageview = [[UIImageView alloc]init];
        imageview.image=[UIImage imageNamed:@"btn_jiantou_you.png"];
        imageview.contentMode = UIViewContentModeCenter;
        self.imageview = imageview;
        [self addSubview:imageview];
        
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        
        self.backgroundColor = [UIColor whiteColor];
        
        self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        
        //下面的线条
        self.lable = [[UILabel alloc]init];
        self.lable.backgroundColor= DRINK_LIGHTGRAY_COLOR;
        [self addSubview:self.lable];
    }
    return self;
}

-(void)layoutSubviews
{
    
    [super layoutSubviews];
    self.contentEdgeInsets = UIEdgeInsetsMake(0,10*KScr, 0, 0);

    self.imageview.frame = CGRectMake(345*KScr, 10*KScr, 11*KScr, 20*KScr);
    
//    self.lable.frame = CGRectMake(10, self.frame.size.height-1, 355, 1);

}
-(void)addline:(NSMutableArray *)arary WithSection:(NSInteger)secction
{
    [self setTitle:[arary objectAtIndex:secction][@"name"] forState:UIControlStateNormal];
    
    self.titleLabel.text = [arary objectAtIndex:secction][@"name"];
    
    self.tag = secction;

    if (arary.count-1 ==secction) {
       self.lable.frame = CGRectMake(0, self.frame.size.height-1, 375*KScr, 1) ;
    }
    else
    {

        self.lable.frame = CGRectMake(10*KScr, self.frame.size.height-1, 355*KScr, 1);
    }
}
-(void)setSelected:(BOOL)selected
{
    [super setSelected:selected];
    if (selected) {
        self.imageview.transform =CGAffineTransformMakeRotation(M_PI_2);
//        self.model.isopen = YES;
    }else
    {
        self.imageview.transform =CGAffineTransformMakeRotation(M_PI_2);
//        self.model.isopen = NO;

    }

}
- (void)didMoveToSuperview
{
    if (self.model.isopen) {
        self.imageview.transform =CGAffineTransformMakeRotation(M_PI_2);

    }

}

//-(void)Hidenline
//{
//
//}
@end
